/*******************************************************************************
 * Package: com.hngtrust.iir.company.controller
 * Type:    BailoutController
 * Date:    2021-4-16 10:40
 *
 * Copyright (c) 2021 HUANENG GUICHENG TRUST CORP.,LTD All Rights Reserved.
 *
 * You may not use this file except in compliance with the License.
 *******************************************************************************/
package com.hngtrust.iir.company.controller;

import com.hngtrust.framework.bind.ResponseInfo;
import com.hngtrust.framework.page.PageResult;
import com.hngtrust.iir.company.controller.vo.ListBondFinanceRespVO;
import com.hngtrust.iir.company.controller.vo.ListDebitCreditRespVO;
import com.hngtrust.iir.company.controller.vo.ListGuaranteeRespVO;
import com.hngtrust.iir.company.controller.vo.ListHolderReqVO;
import com.hngtrust.iir.company.dto.ListFinanceRespDTO;
import com.hngtrust.iir.company.service.BailoutService;
import com.hngtrust.iir.dto.ReqDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 公司融资信息
 * @author Chentianyong
 * @date 2021-4-16 9:25
 */
@Slf4j
@Api(tags = "公司融资信息")
@RestController
@RequestMapping("/company")
public class BailoutController {
    
    @Autowired
    private BailoutService bailoutService;
    
   
    /**
     * 公司融资信息
     */
    @ApiOperation(value = "公司融资信息", notes = "公司融资信息")
    @PostMapping("/list-finance")
    public ResponseInfo<ListFinanceRespDTO> listFinance(
            @ApiParam(value = "公司融资信息") @Valid @RequestBody ListHolderReqVO req) {
        log.info("BailoutController.listFinance start...");
    
        ListFinanceRespDTO resp = bailoutService.listFinance(req);
    
        ResponseInfo<ListFinanceRespDTO> data = new ResponseInfo<>();
        data.setData(resp);
        return data;
    }
    
    /**
     * 公司债股融资
     */
    @ApiOperation(value = "公司债股融资", notes = "公司债股融资")
    @PostMapping("/list-bond-finance")
    public ResponseInfo<PageResult<ListBondFinanceRespVO>> listBondFinance(
            @ApiParam(value = "公司债股融资") @Valid @RequestBody ReqDTO<ListHolderReqVO> req) {
        log.info("BailoutController.listBondFinance start...");
    
        PageResult<ListBondFinanceRespVO> pageResult = bailoutService.listBondFinance(req);
        
        return new ResponseInfo(pageResult);
    }
    
    /**
     * 公司借贷记录
     */
    @ApiOperation(value = "公司借贷记录", notes = "公司借贷记录")
    @PostMapping("/list-debit-credit")
    public ResponseInfo<PageResult<ListDebitCreditRespVO>> listDebitCredit(
            @ApiParam(value = "公司借贷记录") @Valid @RequestBody ReqDTO<ListHolderReqVO> req) {
        log.info("BailoutController.listDebitCredit start...");
    
        PageResult<ListDebitCreditRespVO> pageResult = bailoutService.listDebitCredit(req);
        
        return new ResponseInfo(pageResult);
    }
    
    /**
     * 公司担保记录
     */
    @ApiOperation(value = "公司担保记录", notes = "公司担保记录")
    @PostMapping("/list-guarantee")
    public ResponseInfo<PageResult<ListGuaranteeRespVO>> listGuarantee(
            @ApiParam(value = "公司担保记录") @Valid @RequestBody ReqDTO<ListHolderReqVO> req) {
        log.info("BailoutController.listGuarantee start...");
        
        PageResult<ListGuaranteeRespVO> pageResult = bailoutService.listGuarantee(req);
        
        return new ResponseInfo(pageResult);
    }
}
